package com.itheima.controller;

import com.itheima.feign.FeignService;
import com.itheima.pojo.User;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/consumer")

public class FeignController {
    @Autowired
    private FeignService feignService;
    @GetMapping("/{id}")
   // @HystrixCommand(fallbackMethod = "queryByIdFallBack")
    public User queryById(@PathVariable("id") Long id){
        return this.feignService.queryById(id);
    }

    /*public User queryByIdFallBack(Long id){
        User user=new User();
        user.setId(id);
        user.setName("你有毒，别再来了");
        return user;
    }*/

}
